import axios from 'axios'
const baseUrl = 'http://localhost:8080'


//  请求URL地址
const url = {
    commonAddApi:'',
    loginApi:'http://192.168.0.114:9988/api/SysInfo/test',
    loginApi2:'http://localhost:8080/login2'

}

// 封装获取数据
export const oGet = async (url,params) =>{
    try{
        let res = await axios.get(url.params)
        return res
    }
    catch (err) {
        if(err) console.log(err)
    }
}

//  封装发送数据
export const oPost = async(url,params) =>{
    try {
        let res = await axios.post(url,params)
        return res
    }
    catch (err) {
        if(err) console.log(err)
    }
}

//封装更新数据
export const oUpdate = async(url, params) =>{
    try{
        var res = await axios.patch(url,params);
        return res
    }
    catch(err){
        console.log(err)
    }
}
//封装删除数据
export const oRemove = async(url, params) =>{
    try{
        var res = await axios.delete(url,params);
        return res
    }
    catch(err){
        console.log(err)
    }
}

// 登录方法
export const login = (params) =>{
    return oPost(url.loginApi,params)
}

// get获取数据
export const getData = (params) =>{
    return oGet(url.loginApi,{params:params})
}
